package com.huikeportal.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huikeportal.dao.ReportInfoMapper;
import com.huikeportal.dao.ReportMapper;
import com.huikeportal.model.ReportInfo;
import com.huikeportal.model.WordBook;
import com.huikeportal.service.ReportService;

@Service("reportService")
public class ReportServiceImpl implements ReportService {

	@Autowired
	private ReportMapper reportMapper;

	@Autowired
	private ReportInfoMapper reportInfoMapper;

	public List<ReportInfo> getReportList(String userId) throws Exception {
		return reportMapper.getReportList(userId);
	}

	public String getBookName(String dicKey, String dicCode, String sysLang)
			throws Exception {
		WordBook wordBook = new WordBook();
		wordBook.setDicKey(dicKey);
		wordBook.setDicCode(dicCode);
		wordBook.setLang(sysLang);
		return reportMapper.getBookName(wordBook);
	}

	public List<String> getBookNames(String dicKey, String dicCode,
			String sysLang) throws Exception {
		WordBook wordBook = new WordBook();
		wordBook.setDicKey(dicKey);
		wordBook.setDicCode(dicCode);
		wordBook.setLang(sysLang);
		return reportMapper.getBookNames(wordBook);
	}

	public ReportInfo getReportById(Long reportId) throws Exception {
		return reportInfoMapper.selectByPrimaryKey(reportId);
	}

	public void insertReport(ReportInfo reportInfo) throws Exception {
		reportInfoMapper.insertSelective(reportInfo);
	}

	public void deleteReport(Long reportId) throws Exception {
		reportInfoMapper.deleteByPrimaryKey(reportId);
	}

	public void updateReport(ReportInfo reportInfo) throws Exception {
		reportInfoMapper.updateByPrimaryKeySelective(reportInfo);
	}

}
